<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>主页</title>
<html xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
>
<link rel="stylesheet" href="webjars/easyui-186/1.8.6/themes/black/easyui.css">
<link rel="stylesheet" href="webjars/easyui-186/1.8.6/themes/icon.css">
<link rel="stylesheet" href="static/custom.css" >
<script type="text/javascript" src="webjars/easyui-186/1.8.6/jquery.min.js"></script>
<script type="text/javascript" src="webjars/easyui-186/1.8.6/jquery.easyui.min.js"></script>
<script type="text/javascript" src="webjars/easyui-186/1.8.6/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="static/custom.js"></script>
<style type="text/css">
body {
	margin: 0;
	padding: 0;
}

.middle {
	display: flex;
	flex-direction:column;
	justify-content:center;
	color: #ddd;

}
</style>
<script type="text/javascript">
	function showTab(container, title, src) {
		var tabContainer = $(container);
		if (tabContainer.tabs('exists', title)) {
			var tab = tabContainer.tabs('getTab', title); // 获取选中的选项卡
			var currentTab = tabContainer.tabs('getSelected');
			if (tab == currentTab) {
				tab.panel('refresh', src);
			} else {
				tabContainer.tabs('select', title); //将选中的tab设为当前tab
			}
		} else {
			tabContainer.tabs('add', {
				'title' : title,
				'href' : src,
				'closable' : true
			});
		}
	}
	
	$(function(){
		$('#tabContainer').tabs({
			fit:true
		});
		
		$("#menu .easyui-tree").tree({
			onBeforeSelect:function(node){
				$('#menu div.tree-node-selected').removeClass('tree-node-selected');
			},
			
			onClick : function(node) {
				if (node.text != undefined && node.href != undefined) {
					showTab('#tabContainer', node.title ? node.title : node.text, node.href);
				}
			}
		});
	});

	function xgmm(){
		var dialog = $('#myDialog');
		dialog.dialog({						
			title:'修改密码',
			width: 320,
			height:253,
			closed: false,
			maximizable:true,
			collapsible:true,
			href: 'teacher/pwd',
			buttons:[
				{iconCls: 'icon-save',
					text: '保存',
					handler: function() {
						var dialog = $.dialog.me(this); //取对话框
						var saveUrl = "student/pwd"; 
						var form = $.dialog.form(this); 
						var forms=form[0];
						var pwd1=forms.password1.value;
						var pwd2=forms.password2.value;
						var pwd3=forms.password3.value;
						var params=form.serialize();
						if (pwd1.length == 0) {
							$.messager.alert('提示','密码不能为空');
							return;
						}
					if(pwd2!=pwd3){
						$.messager.alert('提示','两次密码不同');
						return ;
						
					}	
					if (pwd2.length == 0) {
						$.messager.alert('提示','新密码不能为空');
						return;
					}
					if (pwd3.length == 0) {
						$.messager.alert('提示','新密码不能为空');
						return;
					}
					$.post('password/save',params,function(data){				
						alert(data.msg);
						if(data.msg=="修改成功"){
							window.location="login?logout";	
						}
					})

					}}
				,$.dialog.buttons.close]
		})
	}
	function Refresh() {
		window.location="login?logout";
	}

</script>

</head>
<body class="easyui-layout">
	<div class="middle" data-options="region:'north'" style="color:white; height:80px;padding-left:30px;padding-right: 10px;background-color:	#400000">
		<div style="display: flex; flex-direction: row; justify-content: space-between;align-items:center;">
			<span style="font-size: 2.5em;">EasyUI 成绩管理系统</span>
			<div id="myDialog"></div>
			<span sec:authentication="principal.name"  class="easyui-menubutton"     
        		data-options="menu:'#mm',iconCls:'icon-edit'" style="width: 150px; margin-right: 30px;font-size: 1.2em;"></span>   
			<div id="mm" style="width:150px;">   
			    <div data-options="name:'print'" onclick="JavaScript:xgmm()" >修改密码</div>   
				<div data-options="iconCls:'icon-undo'" ><a style="color: #ddd;" href="logout">注销当前用户 </a></div>
			</div>  
		</div>
	</div>
    <div data-options="region:'west',iconCls:'icon-more', title:'主菜单',split:true" style="width:200px;">
		<div id="menu" class="easyui-accordion" fit=true style="width:300px;height:200px;">   
		    <div title="成绩管理" data-options="iconCls:'icon-save'" style="overflow:auto;padding:10px;"
		    sec:authorize="hasRole('ROLE_ADMIN')||hasRole('ROLE_TEACHER')">   
				<ul class="easyui-tree">
					<li data-options="href:'grade/classcourse'">班级成绩录入</li>
					<li data-options="href:'grade/selfgrade'">个人成绩录入</li>
					<li data-options="href:'grade/classgrade'">班级成绩查询</li>
				</ul>
		    </div>   
		    <div title="系统设置" data-options="iconCls:'icon-large-smartart'" 
		    sec:authorize="hasRole('ROLE_ADMIN')||hasRole('ROLE_TEACHER')">   
		        <ul class="easyui-tree">
						<li data-options="href:'course/manage'">课程管理</li>
					 	<li data-options="href:'student/manage'">学生管理</li>  
					 	<li data-options="href:'banji/manage'">班级管理</li>
						<li data-options="href:'teacher/manage'">教师管理</li>				
		        </ul>    
		    </div>
		    <div title="学生操作" data-options="iconCls:'icon-large-smartart'" 
		    sec:authorize="hasRole('ROLE_STUDENT')">   
		        <ul class="easyui-tree">
						<li data-options="href:'grade/self'">个人成绩</li>
					 	<li data-options="href:'grade/classcj'">全班成绩</li>  
		        </ul>    
		    </div>    
		</div>  
    </div>   
    <div class="middle" data-options="region:'south'" style="height:40px;background: #ddd;text-align: center;font-size: 1em;">
    	
    </div>   
    <div data-options="region:'center'" >
		<div id="tabContainer" style="padding: 1px;">
			<div title="首页" style="padding: 10px;" 
			 sec:authorize="hasRole('ROLE_ADMIN')||hasRole('ROLE_TEACHER')">
				<h2>管理员账号：damin</h2>
				<h2>管理员密码：1234</h2>
				<h2>学生账号为学号</h2>
				<h2>学生初始密码为：1111</h2>			
			</div>
		</div>
    </div>   
	

</body>
</html>